package object;



/*
 *测试类,用于对类与对象知识点的理解
 *
 * */
public class Test {
    public static void main(String[] args) {
        // 目标:面向对象编程快速入门
        // 创建对象的格式: 类名 对象名 = new 类名();
        Student s1 = new Student();
        s1.name = "陈平安";
        s1.chinese = 100;
        s1.math = 100;
        s1.printAllScore();
        s1.printAverageScore();

        Student s2 = new Student();
        s1.name = "宁姚";
        s1.chinese = 100;
        s1.math = 100;
        s1.printAllScore();
        s1.printAverageScore();

        //目标:理解多个变量指向同一个对象的问题

        Student s3 = new Student();
        s3.name = "chen";
        System.out.println(s3.name);

        //把学生类型的变量s3赋值给学生类类型的变量s2
        Student s4 = s3;
        s4.name = "chenchen";
        System.out.println(s3.name);
        System.out.println(s4.name);

        s3 = null;
        s4 = null;
        System.out.println(s3.name);//会报空指针异常

    }
}
